$(function () {
    /* 选项卡 */
      $('.lottery-tabs-nav div').click(function () {
          // console.log($(this).index())
          $(this).addClass('on').siblings().removeClass('on');
      $('.reward-people').find('.reward-people-li').eq($(this).index()).addClass('show').siblings().removeClass('show');
      })
    /* 选项卡结束 */
    
    /* 点击抽奖 */
    let lucky = {
        isStop:false,
        speed:50,   //滚动速度
        step:50,    //步数

    }

    function luckyDraw(){
      $('.reward-profile-ul').animate({marginTop:'-2rem'},lucky.speed,function () {
          lucky.speed += lucky.isStop ? lucky.step : -lucky.step;
          lucky.speed = lucky.speed < 50 ? 50 : lucky.speed;
          $('.reward-profile-ul').css('margin-top', 0);
          if(lucky.isStop){
             console.log('中奖了');
          }else {
              luckyDraw();
          }

      })
    }

    let f =false;
    $('.lottery-btn').click(function () {

        if(f=!f){
            lucky.speed = 50;
            lucky.isStop = false;
            luckyDraw();
            $('.lottery-btn p').text('停止');
        }else {
            lucky.isStop = true;
            $('.lottery-btn p').text('开始');
        }
    })
    /* 点击抽奖结束 */


})